package com.app.couponsharelife.ui.popupwindow

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.PopupWindow
import com.app.couponsharelife.R
import com.app.couponsharelife.ui.listener.OnClickListener
import kotlinx.android.synthetic.main.popupwindow_search_content.view.*

/**
 *Created by xct on 2019/5/21
 *Description:复制内容响应弹窗
 */
class SearchContentPopupWindow(private val context: Context, val content : String, private val listener: OnClickListener): PopupWindow(context) {
    init {
        initView()
    }
    private fun initView(){
        val view = LayoutInflater.from(context).inflate(R.layout.popupwindow_search_content, null)
        view.tvPDD.setOnClickListener {
            listener.click(1,"")
            dismiss()
        }
        view.tvTB.setOnClickListener {
            listener.click(0,"")
            dismiss()
        }
        view.ivClose.setOnClickListener { dismiss() }
        view.tvContent.text=content
        height = ViewGroup.LayoutParams.WRAP_CONTENT
        width = ViewGroup.LayoutParams.MATCH_PARENT
        val cd = ColorDrawable(0x00ffffff)// 背景颜色全透明
        this.setBackgroundDrawable(cd)
        this.isFocusable = true
        this.isOutsideTouchable = true
        this.animationStyle = R.style.popupwindow_xiala
        this.contentView = view
    }
}